// pages/search/search.js
const app = getApp()
var util = require('../../utils/util.js')
Page({
  data: {
    navBarHeight: app.globalData.navBarHeight,
    navTop: app.globalData.navTop,
    noticeText: '了解身边的一切，从天算开始。',
    newsList: [
      {
        id: 1,
        title: '天算系统，天算查询',
        imgUrl: 'https://t8.baidu.com/it/u=4193454865,3097077724&fm=3035&app=3035&size=f242,162&n=0&g=0n&f=JPEG?s=D58F0ABE4A6BDEC413019C84030030A9&sec=1683380394&t=ee726089378a3b5af688652849dc21c8'
      },
      {
        id: 2,
        title: '想长寿先养腿！教你5个腿不老的动作，越早做越好',
        imgUrl: 'https://t8.baidu.com/it/u=4193454865,3097077724&fm=3035&app=3035&size=f242,162&n=0&g=0n&f=JPEG?s=D58F0ABE4A6BDEC413019C84030030A9&sec=1683380394&t=ee726089378a3b5af688652849dc21c8'
      },
      {
        id: 3,
        title: '3天算系统，天算查询',
        imgUrl: 'https://t8.baidu.com/it/u=4193454865,3097077724&fm=3035&app=3035&size=f242,162&n=0&g=0n&f=JPEG?s=D58F0ABE4A6BDEC413019C84030030A9&sec=1683380394&t=ee726089378a3b5af688652849dc21c8'
      },
      {
        id: 4,
        title: '4天算系统，天算查询',
        imgUrl: 'https://t8.baidu.com/it/u=4193454865,3097077724&fm=3035&app=3035&size=f242,162&n=0&g=0n&f=JPEG?s=D58F0ABE4A6BDEC413019C84030030A9&sec=1683380394&t=ee726089378a3b5af688652849dc21c8'
      },
      {
        id: 5,
        title: '5天算系统，天算查询',
        imgUrl: 'https://t8.baidu.com/it/u=4193454865,3097077724&fm=3035&app=3035&size=f242,162&n=0&g=0n&f=JPEG?s=D58F0ABE4A6BDEC413019C84030030A9&sec=1683380394&t=ee726089378a3b5af688652849dc21c8'
      },
      {
        id: 6,
        title: '6天算系统，天算查询',
        imgUrl: 'https://t8.baidu.com/it/u=4193454865,3097077724&fm=3035&app=3035&size=f242,162&n=0&g=0n&f=JPEG?s=D58F0ABE4A6BDEC413019C84030030A9&sec=1683380394&t=ee726089378a3b5af688652849dc21c8'
      }
    ],
    searchTxt: ''
  },
  //返回
  goBack(){
    wx.navigateBack();
  },
  //搜索输入监听
  searchInput(e){
    this.setData({
      searchTxt: e.detail.value
    })
  },
  //搜索
  onSearch(){
    let searchTxt = this.data.searchTxt;
    
  },
  //跳转详情
  goInfo(e){
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../newslist/detail?id=' + id,
    })
  },
  //删除
  delNews(e){
    let id = e.currentTarget.dataset.id;
    let index = e.currentTarget.dataset.index;
    let newsList = this.data.newsList;
    // newsList.splice(id,1);
    newsList.splice(index,1);
    this.setData({
      newsList
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})